package cn.edu.scau.cmi.yangzhengkai.client.mainClient;

import org.dom4j.util.SimpleSingleton;

import cn.edu.scau.cmi.yangzhengkai.adapter.AdapterOfObject;
import cn.edu.scau.cmi.yangzhengkai.client.classicsDesignPattern.AbstractFactoryClient;
import cn.edu.scau.cmi.yangzhengkai.client.classicsDesignPattern.AdapterOfClassClient;
import cn.edu.scau.cmi.yangzhengkai.client.classicsDesignPattern.AdapterOfObjectClient;
import cn.edu.scau.cmi.yangzhengkai.client.classicsDesignPattern.ConsistentCompositeClient;
import cn.edu.scau.cmi.yangzhengkai.client.classicsDesignPattern.FactoryClient;
import cn.edu.scau.cmi.yangzhengkai.client.classicsDesignPattern.InterProgrammingClient;
import cn.edu.scau.cmi.yangzhengkai.client.classicsDesignPattern.MultipletonClient;
import cn.edu.scau.cmi.yangzhengkai.client.classicsDesignPattern.SafeCompositeClient;
import cn.edu.scau.cmi.yangzhengkai.client.classicsDesignPattern.SimpleFactoryMethodClient;
import cn.edu.scau.cmi.yangzhengkai.client.classicsDesignPattern.SingletonClient;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.stage.Stage;

public class mainClient extends Application{
	
	public static final int WIDTH = 300;
	public static final int HEIGHT = 50;
	
	public static void main(String[] args) {
		
		launch(args);

	}

	@Override
	public void start(Stage primaryStage) throws Exception {
		FlowPane fp = new FlowPane();
		Button b1 = new Button("实验一:单例模式");
		b1.setPrefSize(WIDTH, HEIGHT);
		b1.setOnMouseClicked(new EventHandler<MouseEvent>() {

			@Override
			public void handle(MouseEvent event) {
				SingletonClient slc = new SingletonClient();
				slc.start(new Stage());
			
				
			}
		});
		Button b2 = new Button("实验一:多例模式");
		b2.setPrefSize(WIDTH, HEIGHT);
		b2.setOnMouseClicked(new EventHandler<MouseEvent>() {

			@Override
			public void handle(MouseEvent event) {
				MultipletonClient mc = new MultipletonClient();
				mc.start(new Stage());
 				
			}
		});
		Button b3 = new Button("实验一:接口编程");
		b3.setPrefSize(WIDTH, HEIGHT);
		b3.setOnMouseClicked(new EventHandler<MouseEvent>() {

			@Override
			public void handle(MouseEvent event) {
				InterProgrammingClient ipc = new InterProgrammingClient();
				ipc.start(new Stage());
				
			}
		});
		Button b4 = new Button("实验二:简单工厂");
		b4.setPrefSize(WIDTH, HEIGHT);
		b4.setOnMouseClicked(new EventHandler<MouseEvent>() {

			@Override
			public void handle(MouseEvent event) {
				SimpleFactoryMethodClient sfmc = new SimpleFactoryMethodClient();
				sfmc.start(new Stage());
				
			}
		});
		Button b5 = new Button("实验二:工厂模式");
		b5.setPrefSize(WIDTH, HEIGHT);
		b5.setOnMouseClicked(new EventHandler<MouseEvent>() {

			@Override
			public void handle(MouseEvent event) {
				FactoryClient fc = new FactoryClient();
				fc.start(new Stage());
				
			}
		});
		Button b6 = new Button("实验二:抽象工厂");
		b6.setPrefSize(WIDTH, HEIGHT);
		b6.setOnMouseClicked(new EventHandler<MouseEvent>() {

			@Override
			public void handle(MouseEvent event) {
				AbstractFactoryClient afc = new AbstractFactoryClient();
				afc.start(new Stage());
			}
		});
		
		Button b7 = new Button("实验三:适配器(对象)");
		b7.setPrefSize(WIDTH, HEIGHT);
		b7.setOnMouseClicked(new EventHandler<MouseEvent>() {

			@Override
			public void handle(MouseEvent event) {
				AdapterOfObjectClient aooc = new AdapterOfObjectClient();
				aooc.start(new Stage());
				
			}
		});
		Button b8 = new Button("实验三:适配器(类)");
		b8.setOnMouseClicked(new EventHandler<MouseEvent>() {

			@Override
			public void handle(MouseEvent event) {
				AdapterOfClassClient aocc = new AdapterOfClassClient();
				aocc.start(new Stage());
				
			}
		});
		b8.setPrefSize(WIDTH, HEIGHT);
		Button b9 = new Button("实验四:安全组合模式");
		b9.setOnMouseClicked(new EventHandler<MouseEvent>() {

			@Override
			public void handle(MouseEvent event) {
				SafeCompositeClient scc = new SafeCompositeClient();
				scc.start(new Stage());
				
			}
		});
		b9.setPrefSize(WIDTH, HEIGHT);
		Button b10 = new Button("实验四:一致性组合模式");
		b10.setOnMouseClicked(new EventHandler<MouseEvent>() {

			@Override
			public void handle(MouseEvent event) {
				ConsistentCompositeClient ccc = new ConsistentCompositeClient();
				ccc.start(new Stage());
				
			}
		});
		b10.setPrefSize(WIDTH, HEIGHT);
		Label lb1 = new Label("",new ImageView(new Image("icon/huge.jpg")));
		Label lb2 = new Label("学号:      201727020129");
		lb2.setFont(new Font(20));
		Label lb3 = new Label("姓名:      杨铮楷");
		lb3.setFont(new Font(20));
		VBox vb1 = new VBox();
//		vb1.setPrefSize(WIDTH, 500);
		VBox vb2 = new VBox();
		vb2.setPrefSize(WIDTH, 500);
		HBox hb = new HBox();
		vb1.getChildren().addAll(lb1,lb2,lb3);
		vb1.setSpacing(10.0);
		vb2.getChildren().addAll(b1,b2,b3,b4,b5,b6,b7,b8,b9,b10);
		hb.getChildren().addAll(vb1,vb2);
		fp.getChildren().add(hb);
		Scene scene = new Scene(fp);
		primaryStage.setScene(scene);
		primaryStage.setTitle("综合性实验");
		primaryStage.setWidth(745);
		primaryStage.setResizable(false);
		primaryStage.show();
		
		
	}

}
